//
//  ForgetPwdThreeViewController.m
//  parent
//
//  Created by 闫珍 on 15/9/29.
//  Copyright © 2015年 ci123. All rights reserved.
//

#import "ForgetPwdThreeViewController.h"
#import "AFAppClient.h"
#import "Tool.h"

@interface ForgetPwdThreeViewController ()
@property (weak, nonatomic) IBOutlet UITextField *pwd;

@end

@implementation ForgetPwdThreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"忘记密码";
    [self CustomBackButton];
}

- (IBAction)submit:(id)sender {
    NSString *add_society_url = [NSString stringWithFormat:@"%@%@",SERVER_URL_NEW,kPhoneResettig];
    [self showHud:@"重置中..." isDim:YES];
    NSString *pass =  _pwd.text;
    NSDictionary *params = @{@"code":_code,@"password":pass,@"phone_num":_phone};
    
    [[AFAppClient sharedManager]getWithURL:add_society_url withParameters:params success:^(NSDictionary *responseObject) {
        [self hideHud2];
        NSUInteger code = [Tool defaultIntFromDic:responseObject withKey:@"code"];
        if(code==1){
            [self showHudComplete:@"密码重置成功，请登录~" success:NO];
            [self.navigationController popToRootViewControllerAnimated:YES];
        }else{
            NSString *msg = [Tool defaultStringFromDic:responseObject withKey:@"result"];
            [self showHudComplete:msg success:NO];
        }
    } failure:^(NSError *error) {
        [self showHudComplete:kNoNetwork success:NO];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
